package main.java.scenes;

import org.xith3d.base.Xith3DEnvironment;
import org.xith3d.loop.UpdatingThread.TimingMode;
import org.xith3d.render.Canvas3D;
import org.xith3d.scenegraph.BranchGroup;
import org.xith3d.scenegraph.primitives.Cube;
import org.xith3d.schedops.movement.RotatableGroup;
import org.xith3d.schedops.movement.TransformationDirectives;


import main.java.MainLoop;
import main.java.ResourceManager;

/**
 * Graphic Experiments/Test experimentation with animator interface
 * 
 * @author Sven Berger
 * 
 * 
 * 
 */

public class TestScene2 implements SceneInterface {
	private ResourceManager ress;
	private Canvas3D canvas3D;
	private Xith3DEnvironment xEnv;
	private MainLoop mainLoop;

	private BranchGroup createScene() {
		final Cube cube = new Cube(3.0f, "stone.jpg");
		cube.setName( "cube" );
		
		/*  TransformGroup tg = new TransformGroup();
         *	tg.addChild( cube );
		 * 
		 */
		
		TransformationDirectives rotDirecs=new TransformationDirectives(0.3f,0.2f,0.0f);
		
		//GroupRotator gr = new GroupRotator( tg, rotDirecs );
		RotatableGroup rg=new RotatableGroup(rotDirecs);
		
		rg.addChild(cube);
		this.mainLoop.getAnimator().addAnimatableObject(rg);

		return (new BranchGroup(rg));
	}

	@Override
	public void onRegister()
	{

	
	}
	
    public void prepareNextFrame( long gameTime, long frameTime, TimingMode tm )
    {

    }

	@Override
	public BranchGroup registerScene(Xith3DEnvironment env, Canvas3D canvas,
			final ResourceManager resourceManager, MainLoop loop) {
		this.ress=resourceManager;
		this.canvas3D=canvas;
		this.xEnv=env;
		this.mainLoop=loop;
		canvas.setBackgroundColor(0.0f, 0.0f, 0.2f);
		BranchGroup br=createScene();
		env.addPerspectiveBranch(br);
		return(br);
		
	}

	@Override
	public void unregisterScene() {
		this.xEnv.removeAllBranchGraphs();
		
	}
}
